
#include <dev.h>
#include "pci.h"

/* ------------------------------------------------------------------------- */

#define VGA_MMIO_SIZE	0x1000000		/* 16MB */
#define VGA_VMEM_SIZE	0x8000000		/* 128MB */

/* ------------------------------------------------------------------------- */

static pci_dev_t vga_dev;

static void fastcall vga_config(uint8 reg, uint32 data, uint32 mask);
static size_t fastcall vga_map_size(uint map);
static size_t fastcall vga_read_map(uint map, uint32 addr, void *data, size_t size);
static size_t fastcall vga_write_map(uint map, uint32 addr, const void *data, size_t size);

/* ------------------------------------------------------------------------- */

pci_dev_t *get_vga_device(void)
{
	memset(&vga_dev, 0, sizeof(vga_dev));

#ifndef NDEBUG
	strcpy(vga_dev.name, "VGA");
#endif

	vga_dev.conf.hdr.type0.base_addr[0] = PCI_BASE_ADDR_MEM;
	vga_dev.conf.hdr.type0.base_addr[1] = PCI_BASE_ADDR_MEM | PCI_BASE_ADDR_MEM_PREFETCH;

	vga_dev.config = &vga_config;
	vga_dev.map_size = &vga_map_size;
	vga_dev.read_map = &vga_read_map;
	vga_dev.write_map = &vga_write_map;

	return &vga_dev;
}

/* ------------------------------------------------------------------------- */

static void fastcall vga_config(uint8 reg, uint32 data, uint32 mask)
{

}

static size_t fastcall vga_map_size(uint map)
{
	switch (map) {
	case 0:
		return VGA_MMIO_SIZE;
	case 1:
		return VGA_VMEM_SIZE;
	}

	return 0;
}

static size_t fastcall vga_read_map(uint map, uint32 addr, void *data, size_t size)
{
	return size;
}

static size_t fastcall vga_write_map(uint map, uint32 addr, const void *data, size_t size)
{
	return size;
}

/* ------------------------------------------------------------------------- */
